package com.tan.model.vo;

import com.tan.model.domain.announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;

@Data
@AllArgsConstructor  //满参构造方法
@NoArgsConstructor   //无参构造方法
public class AnnouncementVo {
    private String id;
    private String title;
    private String description;
    private String createDate;
    public static AnnouncementVo init(announcement announcement) {
        AnnouncementVo vo = new AnnouncementVo();
        BeanUtils.copyProperties(announcement,vo);
        vo.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(announcement.getUpdated()));
        return vo;
    }
}
